Skip to content

dtls13: add check over handshake message length#10769

Open
rizlik wants to merge 1 commit into
wolfSSL:masterfrom
rizlik:dtls13_max_handshake_sz
Open

dtls13: add check over handshake message length#10769
rizlik wants to merge 1 commit into
wolfSSL:masterfrom
rizlik:dtls13_max_handshake_sz

Conversation

@rizlik

@rizlik rizlik commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings June 24, 2026 17:31
@rizlik rizlik self-assigned this Jun 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a DTLS 1.3 safety check to prevent buffering/reassembly of unauthenticated handshake fragments that claim an excessive message_length, and introduces a regression test to ensure oversized plaintext handshake messages are dropped rather than stored.

Changes:

  • Add a MAX_HANDSHAKE_SZ cap check in src/dtls13.c before buffering handshake fragments for reassembly.
  • Add a new DTLS 1.3 memio test that spoofs a plaintext ServerHello handshake message_length to exceed MAX_HANDSHAKE_SZ and asserts nothing is buffered.
  • Register the new test in the DTLS API test declarations.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/api/test_dtls.h Declares and registers the new DTLS 1.3 oversized handshake-length test.
tests/api/test_dtls.c Adds a memio-based regression test that injects an oversized plaintext handshake fragment and checks it isn’t buffered.
src/dtls13.c Caps DTLS 1.3 handshake messageLength prior to fragment buffering; drops oversized plaintext messages and errors on oversized encrypted ones.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/dtls13.c
Comment on lines +1892 to +1896
/* Cap the handshake message size before it can be buffered for reassembly,
* matching the DTLSv1.2 path (DoDtlsHandShakeMsg()). RFC 9147 Sec 4.5.2
* says invalid records SHOULD be silently discarded, so only error out once
* the record is authenticated (received in an encrypted epoch); a plaintext
* message is just dropped. */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants